package components.contorls.superClass
{
    import components.core.UIComponent;
    import components.layout.BaseLayout;
    import components.layout.HLayout;
    
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.geom.Rectangle;
    import flash.utils.getDefinitionByName;
	
    public class BaseStar extends UIComponent
    {
		private var _count:uint=1;
		
		private var _starClassName:String="StarSkin";
		
        public function BaseStar()
        {
            super();
        }

		/***************************************
		 * 
		 * 显示对象声明
		 * 
		 * **************************************/
		
		/***************************************
		 * 
		 * 验证
		 * 
		 * **************************************/
		
        protected override function commitProperties():void
        {
            super.commitProperties();
			
			while(numChildren>0)
			{
				removeChildAt(0);
			}
				
			var starClass:Class;
			for (var i:int = 0; i < count; i++) 
			{
				starClass=Class(getDefinitionByName(starClassName));
				addChild(new starClass());
			}
        }

        protected override function measureSizes():Boolean
        {
            return super.measureSizes();
        }
		
		protected override function updateDisplayList():void
		{
			super.updateDisplayList();
			if(layout)
			{
				myWidth=layout.lastWidth;
				myHeight=layout.lastHeight;
		}
			else
			{
				var rect:Rectangle=getRect(this);
				myWidth=rect.width;
				myHeight=rect.height;
			}
		}
		
        /***************************************
		 * 
		 * 组件定义
		 * 
		 * **************************************/
		
		
        [Inspectable(defaultValue="1")]
        public function get count():uint
        {
            return _count;
        }

        public function set count(value:uint):void
        {
			_count = value;
            invalidate();
        }
		
		[Inspectable(defaultValue="StarSkin")]
		public function get starClassName():String
		{
			return _starClassName;
		}
		
		public function set starClassName(value:String):void
		{
			_starClassName = value;
			invalidate();
		}
    }
}